package com.tk.exam.dao;

import com.github.pagehelper.PageInfo;
import com.tk.exam.domain.TkStudent;
import com.tk.exam.domain.TkStudentExample;
import com.tk.exam.mapper.TkStudentMapper;
import com.tk.exam.vo.StudentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: xujg
 * @Description: TODO
 * @date: 2019-06-17 15:59
 */
@Repository
public class StudentDao {
    @Autowired
    private TkStudentMapper studentMapper;

    public PageInfo<StudentVo> getListWithPage(StudentVo param) {
        return new PageInfo<StudentVo>(this.studentMapper.getListWithPage(param));

    }

    public List<StudentVo> getList(StudentVo param) {
        List<StudentVo> list = studentMapper.getList(param);
        return list;
    }

    public PageInfo<TkStudent> getListOfClassWithPage(String classId) {
        TkStudentExample studentExample = new TkStudentExample();
        studentExample.setOrderByClause("create_time DESC");
        studentExample.createCriteria().andClassIdEqualTo(Integer.parseInt(classId));
        return new PageInfo<TkStudent>(this.studentMapper.selectByExample(studentExample));

    }
}
